package ru.nosport.matrixaria.core;

import java.util.logging.LogManager;
import java.util.logging.Logger;
import java.util.List;
import java.util.ArrayList;

/**
 * User: vfabr
 * Date: 23.11.2006
 * Time: 13:37:22
 */
public class MLogger {
	private static List<Package> allModules = new ArrayList<Package>();

	/**
	 * Sets internal list of all modules' packages to form log files in the future.
	 *
	 * @param _modules -
	 */
	static void setModules(List<ModuleShortcut> _modules) {
		for (ModuleShortcut mod : _modules) {
			allModules.add(mod.getInstanceClass().getPackage());
		}
	}

	/**
	 *
	 * @return List of module packages
	 */
	public static List<Package> getModules() {
		return allModules;
	}

	/**
	 * Returns a logger for the specified object
	 *
	 * @param _obj Logger
	 * @return - 
	 */
	public static Logger get(Object _obj) {
		LogManager lman = LogManager.getLogManager();
		Logger tmpLog = lman.getLogger(_obj.getClass().getName());

		if (tmpLog == null) {
			tmpLog = Logger.getLogger(_obj.getClass().getName());
		}

		return tmpLog;
	}

}
